// maindlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINDLG_H__B7BFD46E_7040_427C_BD37_4351D55C0808__INCLUDED_)
#define AFX_MAINDLG_H__B7BFD46E_7040_427C_BD37_4351D55C0808__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "XDialogImpl.h"
#include "XTitlebar.h"

#define PRICE_CHAR_NUM	100


typedef IXpng *(* CREATEPNGOBJECT)();
//#include "SkinItem.h"

#define WM_DOWNLOADPARSE_FINISH WM_USER+1
#define URL_MAX_SIZE 1024

class CHtmlParser;
class IXpng;
class IXImage;
class CXmlParse;
class CMainDlg : public CXDialogImpl<CMainDlg>/*CDialogImpl<CMainDlg>*/, public CUpdateUI<CMainDlg>,
	public CMessageFilter, public CIdleHandler, public CWinDataExchange<CMainDlg>
{
public:
	CMainDlg();
	~CMainDlg();
	enum { IDD = IDD_MAINDLG };

	virtual BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	virtual BOOL OnIdle()
	{
		return FALSE;
	}


	BEGIN_DDX_MAP(CMainDlg)
		DDX_TEXT(IDC_STATIC_PRICE, m_strLowestPrice)
		DDX_TEXT(IDC_STATIC_PRICETIME, m_strLowestPriceTime)
		DDX_TEXT(IDC_EDIT_URL, m_strUrl)
		DDX_TEXT(IDC_STATIC_CURPRICE, m_strCurrentPrice)
		DDX_TEXT(IDC_STATIC_TIME, m_strCurrentTime)
	END_DDX_MAP()


	BEGIN_UPDATE_UI_MAP(CMainDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColor)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		MESSAGE_HANDLER(WM_DOWNLOADPARSE_FINISH, OnDownloadParseFinish)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
		COMMAND_ID_HANDLER(IDOK, OnOK)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		COMMAND_ID_HANDLER(IDC_BUTTON_ADD, OnAddUrl)
		COMMAND_ID_HANDLER(IDC_BUTTON_CLOSE, OnCancel)
		COMMAND_ID_HANDLER(IDC_BUTTON_MIN, OnMinimize)
		COMMAND_ID_HANDLER(IDC_BUTTON_OPENURL, OnOpenURL)
		MESSAGE_HANDLER(WM_TIMER, OnTimer)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
		MESSAGE_HANDLER(WM_SIZE, OnSize)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)

	END_MSG_MAP()


	LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnAddUrl(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnMinimize(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnOpenURL(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnDownloadParseFinish(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	void CloseDialog(int nVal);

	void GetNewInformation();

	CString GetNameFromUrl(const CString & strURL);
	inline CString GetUrl(){return m_strUrl;};

//	void DrawToBkgrndBitamp();
	void GetConfigPath();
public:
	CHtmlParser *	m_pHtmlParser;
	CBitmap			m_bitmapBkgrn;
// 	IXImage *		m_pBackLayer;
// 	IXImage *		m_pBackPng;	
private:
	CString			m_strUrl;

	CString			m_strCurrentPrice;
	CString			m_strCurrentTime;
	CString			m_strLowestPrice;
	CString			m_strLowestPriceTime;
	SYSTEMTIME		m_LowestTime;
// 	IXpng *			m_pBackPng;
// 	IXpng *			m_pBackLayer;
	

//	CXPngButton		m_button;
//	CXPngButton		m_button1;
//	CXPngButton		m_buttonAdd;
	CXTitlebar		m_TitleBar;
	
// 	CString			m_strConfigPath;
// 	CXmlParse	*	m_pXmlParse;
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MAINDLG_H__B7BFD46E_7040_427C_BD37_4351D55C0808__INCLUDED_)
